package Thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class demo16 {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService Service = Executors.newFixedThreadPool(4);
        for (int i = 0; i < 100; i++) {
            int id = i;
            Service.submit(() -> {
                Thread thread = Thread.currentThread();
                System.out.println("hello,world" + " " + id + thread.getName());
            });
        }
        //防止线程中断
        Thread.sleep(2000);
        //结束所有线程
        Service.shutdown();
    }
}
